<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<WebClient.Models.ViewModels.GroupViewModel>" %>
<%@ Import Namespace="WebClient.Helpers" %>
<div class="AdminPageText">
List Of Contact
</div>
<% using (Html.BeginForm("UpdateContact", "Admin", FormMethod.Post, new { id = "MySubmitForm" })){ %>
<table class="Grid" cellpadding="0" cellspacing="0">
	<thead>
		<tr>
			<th>Email</th>
			<th>Name</th>
			<th>Subject</th>
			<th>Detail</th>
			<th></th>
			<th></th>
		</tr>
	</thead>
	<% for (int i=0; i<Model.ContactModel.GetModel.LstObjModel.Count; i++){
		if (i % 2 != 0) {%>
		<tr class="Row" id="row-<%= Model.ContactModel.GetModel.LstObjModel[i].ID %>">
		<% }
		else { %>
		<tr class="AlternatingRow" id="row-<%= Model.ContactModel.GetModel.LstObjModel[i].ID %>">
		<% } %>
		<% if (Model.ContactModel.GetModel.LstObjModel[i].ID == Model.ContactModel.EditModel.ID){ %>
			<td>
				<%= Html.TextBox("Contact_Email", Model.ContactModel.GetModel.LstObjModel[i].Email, new { @Style = ""})%>
			</td>
			<td>
				<%= Html.TextBox("Contact_Name", Model.ContactModel.GetModel.LstObjModel[i].Name, new { @Style = ""})%>
			</td>
			<td>
				<%= Html.TextBox("Contact_Subject", Model.ContactModel.GetModel.LstObjModel[i].Subject, new { @Style = ""})%>
			</td>
			<td>
				<%= Html.TextBox("Contact_Detail", Model.ContactModel.GetModel.LstObjModel[i].Detail, new { @Style = ""})%>
			</td>
			<td>
				<a href="#" onclick="submitForm();">
					<span style="color: Blue; text-decoration: underline">Update</span>
				</a>
				&nbsp;
				<%= Html.Hidden("Contact_CurrentPage", Model.ContactModel.GetModel.CurrentPage) %>
				<%= Html.Hidden("Contact_ID", Model.ContactModel.GetModel.LstObjModel[i].ID)%>
				<%= Ajax.ActionLink("Cancel", "CancelEditingContact", "Admin", new { page = Model.ContactModel.GetModel.CurrentPage }, new AjaxOptions { UpdateTargetId = "PartialDiv" })%>
			</td>
			<td>
				<%= Ajax.ActionLink("Delete", "DeleteContact", "Admin", new { id = Model.ContactModel.GetModel.LstObjModel[i].ID }, new AjaxOptions{Confirm = "Are you sure you want to Delete it? This action cannot be undone.", HttpMethod = "Delete", OnComplete = "jsonDelete_OnComplete"})%>
			</td>
		<% }else{ %>
			<td><%= Model.ContactModel.GetModel.LstObjModel[i].Email %></td>
			<td><%= Model.ContactModel.GetModel.LstObjModel[i].Name %></td>
			<td><%= Model.ContactModel.GetModel.LstObjModel[i].Subject %></td>
			<td><%= Model.ContactModel.GetModel.LstObjModel[i].Detail %></td>
			<td>
				<%= Ajax.ActionLink("Edit", "EditContact", "Admin", new { page = Model.ContactModel.GetModel.CurrentPage, id = Model.ContactModel.GetModel.LstObjModel[i].ID }, new AjaxOptions { UpdateTargetId = "PartialDiv" })%>
			</td>
			<td>
				<%= Ajax.ActionLink("Delete", "DeleteContact", "Admin", new { id = Model.ContactModel.GetModel.LstObjModel[i].ID }, new AjaxOptions{Confirm = "Are you sure you want to Delete it? This action cannot be undone.", HttpMethod = "Delete", OnComplete = "jsonDelete_OnComplete"})%>
			</td>
		<% } %>
		</tr>
	<% } %>  
</table>
<% } %>
